package org.lex.event;

import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class ProgressSupport {
	private ChangeSupport boundChangeSupport = new ChangeSupport();
	private ChangeSupport progressChangeSupport = new ChangeSupport();

	private int maximum = 100;
	private int progress = 0;

	private ChangeEvent e = new ChangeEvent(this);

	public ProgressSupport() {
		this(100);
	}

	public ProgressSupport(int max) {
		this.setMaximum(max);
	}

	public int getMaximum() {
		return maximum;
	}

	public void setMaximum(int max) {
		this.maximum = max;
		this.boundChangeSupport.fireStateChanged(e);
	}

	public int getProgress() {
		return progress;
	}

	public void setProgress(int progress) {
		this.progress = progress;
		progressChangeSupport.fireStateChanged(e);
	}

	public void addBoundChangeListener(ChangeListener l) {
		boundChangeSupport.add(l);
	}

	public void removeBoundChangeListener(ChangeListener l) {
		boundChangeSupport.remove(l);
	}

	public void addProgressChangeListener(ChangeListener l) {
		progressChangeSupport.add(l);
	}

	public void removeProgressChangeListener(ChangeListener l) {
		progressChangeSupport.remove(l);
	}
}
